//
//  LZViewController.m
//  LZBaseDeviceSDK
//
//  Created by panfei mao on 01/07/2019.
//  Copyright (c) 2019 panfei mao. All rights reserved.
//

#import "LZViewController.h"
#import "LZBaseDeviceManger.h"

@interface LZViewController ()

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UITextView *paramsView;

@end

@implementation LZViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    CGFloat leftMargin = 12.0;
    CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
    CGFloat screenH = [UIScreen mainScreen].bounds.size.height;
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(leftMargin, 64.0, screenW-leftMargin*2, 20)];
    self.titleLabel.font = [UIFont systemFontOfSize:15.0];
    self.titleLabel.textColor = [UIColor blackColor];
    self.titleLabel.text = @"获取基础参数如下：";
    [self.view addSubview:self.titleLabel];
    
    self.paramsView = [[UITextView alloc] initWithFrame:CGRectMake(leftMargin, CGRectGetMaxY(self.titleLabel.frame)+20, screenW-leftMargin*2, screenH - CGRectGetMaxY(self.titleLabel.frame) - 100)];
    self.paramsView.font = [UIFont systemFontOfSize:15.0];
    self.paramsView.textColor = [UIColor blackColor];
    [self.view addSubview:self.paramsView];

    // SDK初始化
    [LZBaseDeviceManger sharedManager];
    // 模拟延时
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        __block LZViewController *weakSelf = self;
        [LZBaseDeviceManger baseDeviceParamsCompleted:^(NSString *environmentParams) {
            NSString *baseParams = environmentParams;
            weakSelf.paramsView.text = baseParams;
            NSLog(@"获取的环境变量 = %@",baseParams);
        }];
    });
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
